1 class Solution {
2 public:
	3 int findMaxForm(vector<string>&strs, int m, int n) {
		4 int len = strs.size();
		5 vector<vector<vector<int>>> dp(len + 1, vector<vector<int>>(m + 1,
			vector<int>(n + 1)));
		6 for (int i = 1; i <= len; i++)
			7 {
			8 
				9 int a = 0, b = 0;
			10 for (auto ch : strs[i - 1])
				11 if (ch == '0') a++;
			12 else b++;
			13 for (int j = m; j >= 0; j--)
				14 for (int k = n; k >= 0; k--)
				15 {
				16 dp[i][j][k] = dp[i - 1][j][k];
				17 if (j >= a && k >= b)
					18 dp[i][j][k] = max(dp[i][j][k], dp[i - 1][j - a][k - b]
						+ 1);
				19 }
			20 }
		21 return dp[len][m][n];
		22
	}
	23
};